<%@ page import="java.util.List" %>
<%@ page import="com.alog.javaee.day37.User" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: 10069212
  Date: 2019/2/21
  Time: 19:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
        List<User> users = new ArrayList<>();
        users.add(new User(1,"sss","d"));
        users.add(new User(2,"ddd","222"));
        users.add(new User(3,"111","eee"));
        request.setAttribute("users", users);
    %>

    <table border="1" width="500" align="center">
        <tr>
            <th>编码</th>
            <th>姓名</th>
            <th>密码</th>
        </tr>
        <c:forEach items="${users}" var="user" varStatus="s">
            <c:if test="${s.count % 2 == 1}">
                <tr bgcolor="red">
                    <td>${user.id}</td>
                    <td>${user.username}</td>
                    <td>${user.password}</td>
                </tr>
            </c:if>

            <c:if test="${s.count % 2 == 0}">
                <tr bgcolor="green">
                    <td>${user.id}</td>
                    <td>${user.username}</td>
                    <td>${user.password}</td>
                </tr>
            </c:if>

        </c:forEach>
    </table>

</body>
</html>
